import React, {useEffect, useState} from 'react';
import UploadBanner from "@/cms/UploadBanner";
import {Button, message} from "antd";

function ScrollAd(props) {
    const [value,setValue] = useState([])
    useEffect(()=>{
        ax.get("/app/getAdList").then(res=>{
            setValue(res.data.banners)
        })
    },[])
    function onSave(){
        ax.post("/app/createAd",{
            banners:value.map(item=>{
                return {
                    url:item.url || item?.response?.message
                }
            })
        }).then(res=>{
            message.success("保存成功")
        })
    }
    return <div>
        <UploadBanner
            onChange={()=>{}}
            value={value}
        />
        <div>
            <Button type={"primary"} onClick={onSave}>保存</Button>
        </div>
    </div>
}

export default ScrollAd;